#include "mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
        : QMainWindow(parent)
{
        QMenuBar *menuBar = new QMenuBar(this);
        QMenu *fileMenu = new QMenu(tr("&File"), menuBar);
        QAction *newFile = new QAction(tr("&New..."), fileMenu);
        fileMenu->addAction(newFile);
        QAction *openFile = new QAction(tr("&Open..."), fileMenu);
        fileMenu->addAction(openFile);
        menuBar->addMenu(fileMenu);
        setMenuBar(menuBar);

        connect(openFile, SIGNAL(triggered()), this, SLOT(fileOpen()));
}

MainWindow::~MainWindow()
{

}

void MainWindow::fileOpen()
{
        QFileDialog *fileDialog = new QFileDialog(this);
        fileDialog->setWindowTitle(tr("Open File"));
        fileDialog->setDirectory(".");
        if(fileDialog->exec() == QDialog::Accepted) {
                QString path = fileDialog->selectedFiles()[0];
                QMessageBox::information(NULL, tr("Path"), tr("You selected\n%1").arg(path));
        } else {
                QMessageBox::information(NULL, tr("Path"), tr("You didn't select any files."));
        }
}
